home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 November / Freeware November 1998.img / dist / fw_elisp-manual-19.idb / usr / freeware / info / elisp-32.z / elisp-32 (.txt)
GNU Info File  |  1998-05-26  |  51KB  |  958 lines

  1. This is Info file elisp, produced by Makeinfo-1.63 from the input file
  2. elisp.texi.
  3.    This version is the edition 2.4.2 of the GNU Emacs Lisp Reference
  4. Manual.  It corresponds to Emacs Version 19.34.
  5.    Published by the Free Software Foundation 59 Temple Place, Suite 330
  6. Boston, MA  02111-1307  USA
  7.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996 Free Software
  8. Foundation, Inc.
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that the
  14. entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that this permission notice may be stated in a
  19. translation approved by the Foundation.
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the section entitled "GNU General Public License" is included
  23. exactly as in the original, and provided that the entire resulting
  24. derived work is distributed under the terms of a permission notice
  25. identical to this one.
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that the section entitled "GNU General Public License"
  29. may be included in a translation approved by the Free Software
  30. Foundation instead of in the original English.
  31. File: elisp,  Node: Time Conversion,  Next: Timers,  Prev: Time of Day,  Up: System Interface
  32. Time Conversion
  33. ===============
  34.    These functions convert time values (lists of two or three integers)
  35. to strings or to calendrical information.  There is also a function to
  36. convert calendrical information to a time value.  You can get time
  37. values from the functions `current-time' (*note Time of Day::.) and
  38. `file-attributes' (*note File Attributes::.).
  39.    Many operating systems are limited to time values that contain 32
  40. bits of information; these systems typically handle only the times from
  41. 1901-12-13 20:45:52 UTC through 2038-01-19 03:14:07 UTC.  However, some
  42. operating systems have larger time values, and can represent times far
  43. in the past or future.
  44.    Time conversion functions always use the Gregorian calendar, even for
  45. dates before the Gregorian calendar was introduced.  Year numbers count
  46. the number of years since the year 1 B.C., and do not skip zero as
  47. traditional Gregorian years do; for example, the year number -37
  48. represents the Gregorian year 38 B.C.
  49.  - Function: format-time-string FORMAT-STRING TIME
  50.      This function converts TIME to a string according to
  51.      FORMAT-STRING.  The argument FORMAT-STRING may contain
  52.      `%'-sequences which say to substitute parts of the time.  Here is a
  53.      table of what the `%'-sequences mean:
  54.     `%a'
  55.           This stands for the abbreviated name of the day of week.
  56.     `%A'
  57.           This stands for the full name of the day of week.
  58.     `%b'
  59.           This stands for the abbreviated name of the month.
  60.     `%B'
  61.           This stands for the full name of the month.
  62.     `%c'
  63.           This is a synonym for `%x %X'.
  64.     `%C'
  65.           This has a locale-specific meaning.  In the default locale
  66.           (named C), it is equivalent to `%A, %B %e, %Y'.
  67.     `%d'
  68.           This stands for the day of month, zero-padded.
  69.     `%D'
  70.           This is a synonym for `%m/%d/%y'.
  71.     `%e'
  72.           This stands for the day of month, blank-padded.
  73.     `%h'
  74.           This is a synonym for `%b'.
  75.     `%H'
  76.           This stands for the hour (00-23).
  77.     `%I'
  78.           This stands for the hour (00-12).
  79.     `%j'
  80.           This stands for the day of the year (001-366).
  81.     `%k'
  82.           This stands for the hour (0-23), blank padded.
  83.     `%l'
  84.           This stands for the hour (1-12), blank padded.
  85.     `%m'
  86.           This stands for the month (01-12).
  87.     `%M'
  88.           This stands for the minute (00-59).
  89.     `%n'
  90.           This stands for a newline.
  91.     `%p'
  92.           This stands for `AM' or `PM', as appropriate.
  93.     `%r'
  94.           This is a synonym for `%I:%M:%S %p'.
  95.     `%R'
  96.           This is a synonym for `%H:%M'.
  97.     `%S'
  98.           This stands for the seconds (00-60).
  99.     `%t'
  100.           This stands for a tab character.
  101.     `%T'
  102.           This is a synonym for `%H:%M:%S'.
  103.     `%U'
  104.           This stands for the week of the year (01-52), assuming that
  105.           weeks start on Sunday.
  106.     `%w'
  107.           This stands for the numeric day of week (0-6).  Sunday is day
  108.           0.
  109.     `%W'
  110.           This stands for the week of the year (01-52), assuming that
  111.           weeks start on Monday.
  112.     `%x'
  113.           This has a locale-specific meaning.  In the default locale
  114.           (named C), it is equivalent to `%D'.
  115.     `%X'
  116.           This has a locale-specific meaning.  In the default locale
  117.           (named C), it is equivalent to `%T'.
  118.     `%y'
  119.           This stands for the year without century (00-99).
  120.     `%Y'
  121.           This stands for the year with century.
  122.     `%Z'
  123.           This stands for the time zone abbreviation.
  124.  - Function: decode-time TIME
  125.      This function converts a time value into calendrical information.
  126.      The return value is a list of nine elements, as follows:
  127.           (SECONDS MINUTES HOUR DAY MONTH YEAR DOW DST ZONE)
  128.      Here is what the elements mean:
  129.     SEC
  130.           The number of seconds past the minute, as an integer between
  131.           0 and 59.
  132.     MINUTE
  133.           The number of minutes past the hour, as an integer between 0
  134.           and 59.
  135.     HOUR
  136.           The hour of the day, as an integer between 0 and 23.
  137.     DAY
  138.           The day of the month, as an integer between 1 and 31.
  139.     MONTH
  140.           The month of the year, as an integer between 1 and 12.
  141.     YEAR
  142.           The year, an integer typically greater than 1900.
  143.     DOW
  144.           The day of week, as an integer between 0 and 6, where 0
  145.           stands for Sunday.
  146.     DST
  147.           `t' if daylight savings time is effect, otherwise `nil'.
  148.     ZONE
  149.           An integer indicating the time zone, as the number of seconds
  150.           east of Greenwich.
  151.      Note that Common Lisp has different meanings for DOW and ZONE.
  152.  - Function: encode-time SECONDS MINUTES HOUR DAY MONTH YEAR &optional
  153.           ...ZONE
  154.      This function is the inverse of `decode-time'.  It converts seven
  155.      items of calendrical data into a time value.  For the meanings of
  156.      the arguments, see the table above under `decode-time'.
  157.      Year numbers less than 100 are treated just like other year
  158.      numbers.  If you want them to stand for years above 1900, you must
  159.      alter them yourself before you call `encode-time'.
  160.      The optional argument ZONE defaults to the current time zone and
  161.      its daylight savings time rules.  If specified, it can be either a
  162.      list (as you would get from `current-time-zone') or an integer (as
  163.      you would get from `decode-time').  The specified zone is used
  164.      without any further alteration for daylight savings time.
  165.      If you pass more than seven arguments to `encode-time', the first
  166.      six are used as SECONDS through YEAR, the last argument is used as
  167.      ZONE, and the arguments in between are ignored.  This feature
  168.      makes it possible to use the elements of a list returned by
  169.      `decode-time' as the arguments to `encode-time', like this:
  170.           (apply 'encode-time (decode-time ...))
  171. File: elisp,  Node: Timers,  Next: Terminal Input,  Prev: Time Conversion,  Up: System Interface
  172. Timers for Delayed Execution
  173. ============================
  174.    You can set up a "timer" to call a function at a specified future
  175. time or after a certain length of idleness.
  176.    Emacs cannot run a timer at any arbitrary point in a Lisp program; it
  177. can run them only when Emacs could accept output from a subprocess:
  178. namely, while waiting or inside certain primitive functions such as
  179. `sit-for' or `read-char' which *can* wait.  Therefore, a timer's
  180. execution may be delayed if Emacs is busy.  However, the time of
  181. execution is very precise if Emacs is idle.
  182.  - Function: run-at-time TIME REPEAT FUNCTION &rest ARGS
  183.      This function arranges to call FUNCTION with arguments ARGS at
  184.      time TIME.  The argument FUNCTION is a function to call later, and
  185.      ARGS are the arguments to give it when it is called.  The time
  186.      TIME is specified as a string.
  187.      Absolute times may be specified in a variety of formats; The form
  188.      `HOUR:MIN:SEC TIMEZONE MONTH/DAY/YEAR', where all fields are
  189.      numbers, works; the format that `current-time-string' returns is
  190.      also allowed.
  191.      To specify a relative time, use numbers followed by units.  For
  192.      example:
  193.     `1 min'
  194.           denotes 1 minute from now.
  195.     `1 min 5 sec'
  196.           denotes 65 seconds from now.
  197.     `1 min 2 sec 3 hour 4 day 5 week 6 fortnight 7 month 8 year'
  198.           denotes exactly 103 months, 123 days, and 10862 seconds from
  199.           now.
  200.      If TIME is a number (integer or floating point), that specifies a
  201.      relative time measured in seconds.
  202.      The argument REPEAT specifies how often to repeat the call.  If
  203.      REPEAT is `nil', there are no repetitions; FUNCTION is called just
  204.      once, at TIME.  If REPEAT is a number, it specifies a repetition
  205.      period measured in seconds.  In any case, REPEAT has no effect on
  206.      when *first* call takes place--TIME alone specifies that.
  207.      The function `run-at-time' returns a timer value that identifies
  208.      the particular scheduled future action.  You can use this value to
  209.      call `cancel-timer' (see below).
  210.  - Macro: with-timeout (SECONDS TIMEOUT-FORMS...) BODY...
  211.      Execute BODY, but give up after SECONDS seconds.  If BODY finishes
  212.      before the time is up, `with-timeout' returns the value of the
  213.      last form in BODY.  If, however, the execution of BODY is cut
  214.      short by the timeout, then `with-timeout' executes all the
  215.      TIMEOUT-FORMS and returns the value of the last of them.
  216.      This macro works by set a timer to run after SECONDS seconds.  If
  217.      BODY finishes before that time, it cancels the timer.  If the
  218.      timer actually runs, it terminates execution of BODY, then
  219.      executes TIMEOUT-FORMS.
  220.      Since timers can run within a Lisp program only when the program
  221.      calls a primitive that can wait, `with-timeout' cannot stop
  222.      executing BODY while it is in the midst of a computation--only
  223.      when it calls one of those primitives.  So use `with-timeout' only
  224.      with a BODY that waits for input, not one that does a long
  225.      computation.
  226.    The function `y-or-n-p-with-timeout' provides a simple way to use a
  227. timer to avoid waiting too long for an answer.  *Note Yes-or-No
  228. Queries::.
  229.  - Function: run-with-idle-timer SECS REPEAT FUNCTION &rest ARGS
  230.      Set up a timer which runs when Emacs has been idle for SECS
  231.      seconds.  The value of SECS may be an integer or a floating point
  232.      number.
  233.      If REPEAT is `nil', the timer runs just once, the first time Emacs
  234.      remains idle for a long enough time.  More often REPEAT is
  235.      non-`nil', which means to run the timer *each time* Emacs remains
  236.      idle for SECS seconds.
  237.      The function `run-with-idle-timer' returns a timer value which you
  238.      can use in calling `cancel-timer' (see below).
  239.    Emacs becomes "idle" when it starts waiting for user input, and it
  240. remains idle until the user provides some input.  If a timer is set for
  241. five seconds of idleness, it runs approximately five seconds after Emacs
  242. first became idle.  Even if its REPEAT is true, this timer will not run
  243. again as long as Emacs remains idle, because the duration of idleness
  244. will continue to increase and will not go down to five seconds again.
  245.    Emacs can do various things while idle: garbage collect, autosave or
  246. handle data from a subprocess.  But these interludes during idleness
  247. have little effect on idle timers.  An idle timer set for 600 seconds
  248. will run when ten minutes have elapsed since the last user command was
  249. finished, even if subprocess output has been accepted thousands of times
  250. within those ten minutes, even if there have been garbage collections
  251. and autosaves.
  252.    When the user supplies input, Emacs becomes non-idle while executing
  253. the input.  Then it becomes idle again, and all the idle timers that are
  254. set up to repeat will subsequently run another time, one by one.
  255.  - Function: cancel-timer TIMER
  256.      Cancel the requested action for TIMER, which should be a value
  257.      previously returned by `run-at-time' or `run-with-idle-timer'.
  258.      This cancels the effect of that call to `run-at-time'; the arrival
  259.      of the specified time will not cause anything special to happen.
  260. File: elisp,  Node: Terminal Input,  Next: Terminal Output,  Prev: Timers,  Up: System Interface
  261. Terminal Input
  262. ==============
  263.    This section describes functions and variables for recording or
  264. manipulating terminal input.  See *Note Display::, for related
  265. functions.
  266. * Menu:
  267. * Input Modes::        Options for how input is processed.
  268. * Translating Input::   Low level conversion of some characters or events
  269.               into others.
  270. * Recording Input::    Saving histories of recent or all input events.
  271. File: elisp,  Node: Input Modes,  Next: Translating Input,  Up: Terminal Input
  272. Input Modes
  273. -----------
  274.  - Function: set-input-mode INTERRUPT FLOW META QUIT-CHAR
  275.      This function sets the mode for reading keyboard input.  If
  276.      INTERRUPT is non-null, then Emacs uses input interrupts.  If it is
  277.      `nil', then it uses CBREAK mode.  When Emacs communicates directly
  278.      with X, it ignores this argument and uses interrupts if that is
  279.      the way it knows how to communicate.
  280.      If FLOW is non-`nil', then Emacs uses XON/XOFF (`C-q', `C-s') flow
  281.      control for output to the terminal.  This has no effect except in
  282.      CBREAK mode.  *Note Flow Control::.
  283.      The default setting is system dependent.  Some systems always use
  284.      CBREAK mode regardless of what is specified.
  285.      The argument META controls support for input character codes above
  286.      127.  If META is `t', Emacs converts characters with the 8th bit
  287.      set into Meta characters.  If META is `nil', Emacs disregards the
  288.      8th bit; this is necessary when the terminal uses it as a parity
  289.      bit.  If META is neither `t' nor `nil', Emacs uses all 8 bits of
  290.      input unchanged.  This is good for terminals using European 8-bit
  291.      character sets.
  292.      If QUIT-CHAR is non-`nil', it specifies the character to use for
  293.      quitting.  Normally this character is `C-g'.  *Note Quitting::.
  294.    The `current-input-mode' function returns the input mode settings
  295. Emacs is currently using.
  296.  - Function: current-input-mode
  297.      This function returns current mode for reading keyboard input.  It
  298.      returns a list, corresponding to the arguments of `set-input-mode',
  299.      of the form `(INTERRUPT FLOW META QUIT)' in which:
  300.     INTERRUPT
  301.           is non-`nil' when Emacs is using interrupt-driven input.  If
  302.           `nil', Emacs is using CBREAK mode.
  303.     FLOW
  304.           is non-`nil' if Emacs uses XON/XOFF (`C-q', `C-s') flow
  305.           control for output to the terminal.  This value has no effect
  306.           unless INTERRUPT is non-`nil'.
  307.     META
  308.           is `t' if Emacs treats the eighth bit of input characters as
  309.           the meta bit; `nil' means Emacs clears the eighth bit of every
  310.           input character; any other value means Emacs uses all eight
  311.           bits as the basic character code.
  312.     QUIT
  313.           is the character Emacs currently uses for quitting, usually
  314.           `C-g'.
  315. File: elisp,  Node: Translating Input,  Next: Recording Input,  Prev: Input Modes,  Up: Terminal Input
  316. Translating Input Events
  317. ------------------------
  318.    This section describes features for translating input events into
  319. other input events before they become part of key sequences.  These
  320. features apply to each event in the order they are described here: each
  321. event is first modified according to `extra-keyboard-modifiers', then
  322. translated through `keyboard-translate-table' (if applicable).  If it
  323. is being read as part of a key sequence, it is then added to the
  324. sequece being read; then subsequences containing it are checked first
  325. with `function-key-map' and then with `key-translation-map'.
  326.  - Variable: extra-keyboard-modifiers
  327.      This variable lets Lisp programs "press" the modifier keys on the
  328.      keyboard.  The value is a bit mask:
  329.     1
  330.           The SHIFT key.
  331.     2
  332.           The LOCK key.
  333.     4
  334.           The CTL key.
  335.     8
  336.           The META key.
  337.      Each time the user types a keyboard key, it is altered as if the
  338.      modifier keys specified in the bit mask were held down.
  339.      When using X windows, the program can "press" any of the modifier
  340.      keys in this way.  Otherwise, only the CTL and META keys can be
  341.      virtually pressed.
  342.  - Variable: keyboard-translate-table
  343.      This variable is the translate table for keyboard characters.  It
  344.      lets you reshuffle the keys on the keyboard without changing any
  345.      command bindings.  Its value must be a string or `nil'.
  346.      If `keyboard-translate-table' is a string, then each character read
  347.      from the keyboard is looked up in this string and the character in
  348.      the string is used instead.  If the string is of length N,
  349.      character codes N and up are untranslated.
  350.      In the example below, we set `keyboard-translate-table' to a
  351.      string of 128 characters.  Then we fill it in to swap the
  352.      characters `C-s' and `C-\' and the characters `C-q' and `C-^'.
  353.      Subsequently, typing `C-\' has all the usual effects of typing
  354.      `C-s', and vice versa.  (*Note Flow Control:: for more information
  355.      on this subject.)
  356.           (defun evade-flow-control ()
  357.             "Replace C-s with C-\ and C-q with C-^."
  358.             (interactive)
  359.             (let ((the-table (make-string 128 0)))
  360.               (let ((i 0))
  361.                 (while (< i 128)
  362.                   (aset the-table i i)
  363.                   (setq i (1+ i))))
  364.               ;; Swap `C-s' and `C-\'.
  365.               (aset the-table ?\034 ?\^s)
  366.               (aset the-table ?\^s ?\034)
  367.               ;; Swap `C-q' and `C-^'.
  368.               (aset the-table ?\036 ?\^q)
  369.               (aset the-table ?\^q ?\036)
  370.               (setq keyboard-translate-table the-table)))
  371.      Note that this translation is the first thing that happens to a
  372.      character after it is read from the terminal.  Record-keeping
  373.      features such as `recent-keys' and dribble files record the
  374.      characters after translation.
  375.  - Function: keyboard-translate FROM TO
  376.      This function modifies `keyboard-translate-table' to translate
  377.      character code FROM into character code TO.  It creates or
  378.      enlarges the translate table if necessary.
  379.    The remaining translation features translate subsequences of key
  380. sequences being read.  They are implemented in `read-key-sequence' and
  381. have no effect on `read-char'.
  382.  - Variable: function-key-map
  383.      This variable holds a keymap that describes the character sequences
  384.      sent by function keys on an ordinary character terminal.  This
  385.      keymap uses the same data structure as other keymaps, but is used
  386.      differently: it specifies translations to make while reading event
  387.      sequences.
  388.      If `function-key-map' "binds" a key sequence K to a vector V, then
  389.      when K appears as a subsequence *anywhere* in a key sequence, it
  390.      is replaced with the events in V.
  391.      For example, VT100 terminals send `ESC O P' when the keypad PF1
  392.      key is pressed.  Therefore, we want Emacs to translate that
  393.      sequence of events into the single event `pf1'.  We accomplish
  394.      this by "binding" `ESC O P' to `[pf1]' in `function-key-map', when
  395.      using a VT100.
  396.      Thus, typing `C-c PF1' sends the character sequence `C-c ESC O P';
  397.      later the function `read-key-sequence' translates this back into
  398.      `C-c PF1', which it returns as the vector `[?\C-c pf1]'.
  399.      Entries in `function-key-map' are ignored if they conflict with
  400.      bindings made in the minor mode, local, or global keymaps.  The
  401.      intent is that the character sequences that function keys send
  402.      should not have command bindings in their own right.
  403.      The value of `function-key-map' is usually set up automatically
  404.      according to the terminal's Terminfo or Termcap entry, but
  405.      sometimes those need help from terminal-specific Lisp files.
  406.      Emacs comes with terminal-specific files for many common
  407.      terminals; their main purpose is to make entries in
  408.      `function-key-map' beyond those that can be deduced from Termcap
  409.      and Terminfo.  *Note Terminal-Specific::.
  410.      Emacs versions 18 and earlier used totally different means of
  411.      detecting the character sequences that represent function keys.
  412.  - Variable: key-translation-map
  413.      This variable is another keymap used just like `function-key-map'
  414.      to translate input events into other events.  It differs from
  415.      `function-key-map' in two ways:
  416.         * `key-translation-map' goes to work after `function-key-map' is
  417.           finished; it receives the results of translation by
  418.           `function-key-map'.
  419.         * `key-translation-map' overrides actual key bindings.  For
  420.           example, if `C-x f' has a binding in `key-translation-map',
  421.           that translation takes effect even though `C-x f' also has a
  422.           key binding in the global map.
  423.      The intent of `key-translation-map' is for users to map one
  424.      character set to another, including ordinary characters normally
  425.      bound to `self-insert-command'.
  426.    You can use `function-key-map' or `key-translation-map' for more
  427. than simple aliases, by using a function, instead of a key sequence, as
  428. the "translation" of a key.  Then this function is called to compute
  429. the translation of that key.
  430.    The key translation function receives one argument, which is the
  431. prompt that was specified in `read-key-sequence'--or `nil' if the key
  432. sequence is being read by the editor command loop.  In most cases you
  433. can ignore the prompt value.
  434.    If the function reads input itself, it can have the effect of
  435. altering the event that follows.  For example, here's how to define
  436. `C-c h' to turn the character that follows into a Hyper character:
  437.      (defun hyperify (prompt)
  438.        (let ((e (read-event)))
  439.          (vector (if (numberp e)
  440.                      (logior (lsh 1 20) e)
  441.                    (if (memq 'hyper (event-modifiers e))
  442.                        e
  443.                      (add-event-modifier "H-" e))))))
  444.      
  445.      (defun add-event-modifier (string e)
  446.        (let ((symbol (if (symbolp e) e (car e))))
  447.          (setq symbol (intern (concat string
  448.                                       (symbol-name symbol))))
  449.          (if (symbolp e)
  450.              symbol
  451.            (cons symbol (cdr e)))))
  452.      
  453.      (define-key function-key-map "\C-ch" 'hyperify)
  454.    The `iso-transl' library uses this feature to provide a way of
  455. inputting non-ASCII Latin-1 characters.
  456. File: elisp,  Node: Recording Input,  Prev: Translating Input,  Up: Terminal Input
  457. Recording Input
  458. ---------------
  459.  - Function: recent-keys
  460.      This function returns a vector containing the last 100 input events
  461.      from the keyboard or mouse.  All input events are included,
  462.      whether or not they were used as parts of key sequences.  Thus,
  463.      you always get the last 100 inputs, not counting keyboard macros.
  464.      (Events from keyboard macros are excluded because they are less
  465.      interesting for debugging; it should be enough to see the events
  466.      that invoked the macros.)
  467.  - Command: open-dribble-file FILENAME
  468.      This function opens a "dribble file" named FILENAME.  When a
  469.      dribble file is open, each input event from the keyboard or mouse
  470.      (but not those from keyboard macros) is written in that file.  A
  471.      non-character event is expressed using its printed representation
  472.      surrounded by `<...>'.
  473.      You close the dribble file by calling this function with an
  474.      argument of `nil'.
  475.      This function is normally used to record the input necessary to
  476.      trigger an Emacs bug, for the sake of a bug report.
  477.           (open-dribble-file "~/dribble")
  478.                => nil
  479.    See also the `open-termscript' function (*note Terminal Output::.).
  480. File: elisp,  Node: Terminal Output,  Next: Special Keysyms,  Prev: Terminal Input,  Up: System Interface
  481. Terminal Output
  482. ===============
  483.    The terminal output functions send output to the terminal or keep
  484. track of output sent to the terminal.  The variable `baud-rate' tells
  485. you what Emacs thinks is the output speed of the terminal.
  486.  - Variable: baud-rate
  487.      This variable's value is the output speed of the terminal, as far
  488.      as Emacs knows.  Setting this variable does not change the speed
  489.      of actual data transmission, but the value is used for
  490.      calculations such as padding.  It also affects decisions about
  491.      whether to scroll part of the screen or repaint--even when using a
  492.      window system.  (We designed it this way despite the fact that a
  493.      window system has no true "output speed", to give you a way to
  494.      tune these decisions.)
  495.      The value is measured in baud.
  496.    If you are running across a network, and different parts of the
  497. network work at different baud rates, the value returned by Emacs may be
  498. different from the value used by your local terminal.  Some network
  499. protocols communicate the local terminal speed to the remote machine, so
  500. that Emacs and other programs can get the proper value, but others do
  501. not.  If Emacs has the wrong value, it makes decisions that are less
  502. than optimal.  To fix the problem, set `baud-rate'.
  503.  - Function: baud-rate
  504.      This function returns the value of the variable `baud-rate'.  In
  505.      Emacs versions 18 and earlier, this was the only way to find out
  506.      the terminal speed.
  507.  - Function: send-string-to-terminal STRING
  508.      This function sends STRING to the terminal without alteration.
  509.      Control characters in STRING have terminal-dependent effects.
  510.      One use of this function is to define function keys on terminals
  511.      that have downloadable function key definitions.  For example,
  512.      this is how on certain terminals to define function key 4 to move
  513.      forward four characters (by transmitting the characters `C-u C-f'
  514.      to the computer):
  515.           (send-string-to-terminal "\eF4\^U\^F")
  516.                => nil
  517.  - Command: open-termscript FILENAME
  518.      This function is used to open a "termscript file" that will record
  519.      all the characters sent by Emacs to the terminal.  It returns
  520.      `nil'.  Termscript files are useful for investigating problems
  521.      where Emacs garbles the screen, problems that are due to incorrect
  522.      Termcap entries or to undesirable settings of terminal options more
  523.      often than to actual Emacs bugs.  Once you are certain which
  524.      characters were actually output, you can determine reliably
  525.      whether they correspond to the Termcap specifications in use.
  526.      See also `open-dribble-file' in *Note Terminal Input::.
  527.           (open-termscript "../junk/termscript")
  528.                => nil
  529. File: elisp,  Node: Special Keysyms,  Next: Flow Control,  Prev: Terminal Output,  Up: System Interface
  530. System-Specific X11 Keysyms
  531. ===========================
  532.    To define system-specific X11 keysyms, set the variable
  533. `system-key-alist'.
  534.  - Variable: system-key-alist
  535.      This variable's value should be an alist with one element for each
  536.      system-specific keysym.  An element has this form: `(CODE .
  537.      SYMBOL)', where CODE is the numeric keysym code (not including the
  538.      "vendor specific" bit, 1 << 28), and SYMBOL is the name for the
  539.      function key.
  540.      For example `(168 . mute-acute)' defines a system-specific key used
  541.      by HP X servers whose numeric code is (1 << 28) + 168.
  542.      It is not a problem if the alist defines keysyms for other X
  543.      servers, as long as they don't conflict with the ones used by the
  544.      X server actually in use.
  545.      The variable is always local to the current X terminal and cannot
  546.      be buffer-local.  *Note Multiple Displays::.
  547. File: elisp,  Node: Flow Control,  Next: Batch Mode,  Prev: Special Keysyms,  Up: System Interface
  548. Flow Control
  549. ============
  550.    This section attempts to answer the question "Why does Emacs choose
  551. to use flow-control characters in its command character set?"  For a
  552. second view on this issue, read the comments on flow control in the
  553. `emacs/INSTALL' file from the distribution; for help with Termcap
  554. entries and DEC terminal concentrators, see `emacs/etc/TERMS'.
  555.    At one time, most terminals did not need flow control, and none used
  556. `C-s' and `C-q' for flow control.  Therefore, the choice of `C-s' and
  557. `C-q' as command characters was uncontroversial.  Emacs, for economy of
  558. keystrokes and portability, used nearly all the ASCII control
  559. characters, with mnemonic meanings when possible; thus, `C-s' for
  560. search and `C-q' for quote.
  561.    Later, some terminals were introduced which required these characters
  562. for flow control.  They were not very good terminals for full-screen
  563. editing, so Emacs maintainers did not pay attention.  In later years,
  564. flow control with `C-s' and `C-q' became widespread among terminals,
  565. but by this time it was usually an option.  And the majority of users,
  566. who can turn flow control off, were unwilling to switch to less
  567. mnemonic key bindings for the sake of flow control.
  568.    So which usage is "right", Emacs's or that of some terminal and
  569. concentrator manufacturers?  This question has no simple answer.
  570.    One reason why we are reluctant to cater to the problems caused by
  571. `C-s' and `C-q' is that they are gratuitous.  There are other
  572. techniques (albeit less common in practice) for flow control that
  573. preserve transparency of the character stream.  Note also that their use
  574. for flow control is not an official standard.  Interestingly, on the
  575. model 33 teletype with a paper tape punch (which is very old), `C-s'
  576. and `C-q' were sent by the computer to turn the punch on and off!
  577.    As X servers and other window systems replace character-only
  578. terminals, this problem is gradually being cured.  For the mean time,
  579. Emacs provides a convenient way of enabling flow control if you want it:
  580. call the function `enable-flow-control'.
  581.  - Function: enable-flow-control
  582.      This function enables use of `C-s' and `C-q' for output flow
  583.      control, and provides the characters `C-\' and `C-^' as aliases
  584.      for them using `keyboard-translate-table' (*note Translating
  585.      Input::.).
  586.    You can use the function `enable-flow-control-on' in your `.emacs'
  587. file to enable flow control automatically on certain terminal types.
  588.  - Function: enable-flow-control-on &rest TERMTYPES
  589.      This function enables flow control, and the aliases `C-\' and
  590.      `C-^', if the terminal type is one of TERMTYPES.  For example:
  591.           (enable-flow-control-on "vt200" "vt300" "vt101" "vt131")
  592.    Here is how `enable-flow-control' does its job:
  593.   1. It sets CBREAK mode for terminal input, and tells the operating
  594.      system to handle flow control, with `(set-input-mode nil t)'.
  595.   2. It sets up `keyboard-translate-table' to translate `C-\' and `C-^'
  596.      into `C-s' and `C-q'.  Except at its very lowest level, Emacs
  597.      never knows that the characters typed were anything but `C-s' and
  598.      `C-q', so you can in effect type them as `C-\' and `C-^' even when
  599.      they are input for other commands.  *Note Translating Input::.
  600.    If the terminal is the source of the flow control characters, then
  601. once you enable kernel flow control handling, you probably can make do
  602. with less padding than normal for that terminal.  You can reduce the
  603. amount of padding by customizing the Termcap entry.  You can also
  604. reduce it by setting `baud-rate' to a smaller value so that Emacs uses
  605. a smaller speed when calculating the padding needed.  *Note Terminal
  606. Output::.
  607. File: elisp,  Node: Batch Mode,  Prev: Flow Control,  Up: System Interface
  608. Batch Mode
  609. ==========
  610.    The command line option `-batch' causes Emacs to run
  611. noninteractively.  In this mode, Emacs does not read commands from the
  612. terminal, it does not alter the terminal modes, and it does not expect
  613. to be outputting to an erasable screen.  The idea is that you specify
  614. Lisp programs to run; when they are finished, Emacs should exit.  The
  615. way to specify the programs to run is with `-l FILE', which loads the
  616. library named FILE, and `-f FUNCTION', which calls FUNCTION with no
  617. arguments.
  618.    Any Lisp program output that would normally go to the echo area,
  619. either using `message' or using `prin1', etc., with `t' as the stream,
  620. goes instead to Emacs's standard error descriptor when in batch mode.
  621. Thus, Emacs behaves much like a noninteractive application program.
  622. (The echo area output that Emacs itself normally generates, such as
  623. command echoing, is suppressed entirely.)
  624.  - Variable: noninteractive
  625.      This variable is non-`nil' when Emacs is running in batch mode.
  626. File: elisp,  Node: Display,  Next: Calendar,  Prev: System Interface,  Up: Top
  627. Emacs Display
  628. *************
  629.    This chapter describes a number of features related to the display
  630. that Emacs presents to the user.
  631. * Menu:
  632. * Refresh Screen::      Clearing the screen and redrawing everything on it.
  633. * Screen Size::         How big is the Emacs screen.
  634. * Truncation::          Folding or wrapping long text lines.
  635. * The Echo Area::       Where messages are displayed.
  636. * Invisible Text::      Hiding part of the buffer text.
  637. * Selective Display::   Hiding part of the buffer text (the old way).
  638. * Overlay Arrow::       Display of an arrow to indicate position.
  639. * Temporary Displays::  Displays that go away automatically.
  640. * Overlays::        Use overlays to highlight parts of the buffer.
  641. * Faces::        A face defines a graphics appearance: font, color, etc.
  642. * Blinking::            How Emacs shows the matching open parenthesis.
  643. * Inverse Video::    Specifying how the screen looks.
  644. * Usual Display::    The usual conventions for displaying nonprinting chars.
  645. * Display Tables::    How to specify other conventions.
  646. * Beeping::             Audible signal to the user.
  647. * Window Systems::      Which window system is being used.
  648. File: elisp,  Node: Refresh Screen,  Next: Screen Size,  Up: Display
  649. Refreshing the Screen
  650. =====================
  651.    The function `redraw-frame' redisplays the entire contents of a
  652. given frame.  *Note Frames::.
  653.  - Function: redraw-frame FRAME
  654.      This function clears and redisplays frame FRAME.
  655.    Even more powerful is `redraw-display':
  656.  - Command: redraw-display
  657.      This function clears and redisplays all visible frames.
  658.    Processing user input takes absolute priority over redisplay.  If you
  659. call these functions when input is available, they do nothing
  660. immediately, but a full redisplay does happen eventually--after all the
  661. input has been processed.
  662.    Normally, suspending and resuming Emacs also refreshes the screen.
  663. Some terminal emulators record separate contents for display-oriented
  664. programs such as Emacs and for ordinary sequential display.  If you are
  665. using such a terminal, you might want to inhibit the redisplay on
  666. resumption.
  667.  - Variable: no-redraw-on-reenter
  668.      This variable controls whether Emacs redraws the entire screen
  669.      after it has been suspended and resumed.  Non-`nil' means yes,
  670.      `nil' means no.
  671. File: elisp,  Node: Screen Size,  Next: Truncation,  Prev: Refresh Screen,  Up: Display
  672. Screen Size
  673. ===========
  674.    The screen size functions access or specify the height or width of
  675. the terminal.  When you are using multiple frames, they apply to the
  676. selected frame (*note Frames::.).
  677.  - Function: screen-height
  678.      This function returns the number of lines on the screen that are
  679.      available for display.
  680.           (screen-height)
  681.                => 50
  682.  - Function: screen-width
  683.      This function returns the number of columns on the screen that are
  684.      available for display.
  685.           (screen-width)
  686.                => 80
  687.  - Function: set-screen-height LINES &optional NOT-ACTUAL-SIZE
  688.      This function declares that the terminal can display LINES lines.
  689.      The sizes of existing windows are altered proportionally to fit.
  690.      If NOT-ACTUAL-SIZE is non-`nil', then Emacs displays LINES lines
  691.      of output, but does not change its value for the actual height of
  692.      the screen.  (Knowing the correct actual size may be necessary for
  693.      correct cursor positioning.)  Using a smaller height than the
  694.      terminal actually implements may be useful to reproduce behavior
  695.      observed on a smaller screen, or if the terminal malfunctions when
  696.      using its whole screen.
  697.      If LINES is different from what it was previously, then the entire
  698.      screen is cleared and redisplayed using the new size.
  699.      This function returns `nil'.
  700.  - Function: set-screen-width COLUMNS &optional NOT-ACTUAL-SIZE
  701.      This function declares that the terminal can display COLUMNS
  702.      columns.  The details are as in `set-screen-height'.
  703. File: elisp,  Node: Truncation,  Next: The Echo Area,  Prev: Screen Size,  Up: Display
  704. Truncation
  705. ==========
  706.    When a line of text extends beyond the right edge of a window, the
  707. line can either be continued on the next screen line, or truncated to
  708. one screen line.  The additional screen lines used to display a long
  709. text line are called "continuation" lines.  Normally, a `$' in the
  710. rightmost column of the window indicates truncation; a `\' on the
  711. rightmost column indicates a line that "wraps" or is continued onto the
  712. next line.  (The display table can specify alternative indicators; see
  713. *Note Display Tables::.)
  714.    Note that continuation is different from filling; continuation
  715. happens on the screen only, not in the buffer contents, and it breaks a
  716. line precisely at the right margin, not at a word boundary.  *Note
  717. Filling::.
  718.  - User Option: truncate-lines
  719.      This buffer-local variable controls how Emacs displays lines that
  720.      extend beyond the right edge of the window.  The default is `nil',
  721.      which specifies continuation.  If the value is non-`nil', then
  722.      these lines are truncated.
  723.      If the variable `truncate-partial-width-windows' is non-`nil',
  724.      then truncation is always used for side-by-side windows (within one
  725.      frame) regardless of the value of `truncate-lines'.
  726.  - User Option: default-truncate-lines
  727.      This variable is the default value for `truncate-lines', for
  728.      buffers that do not have local values for it.
  729.  - User Option: truncate-partial-width-windows
  730.      This variable controls display of lines that extend beyond the
  731.      right edge of the window, in side-by-side windows (*note Splitting
  732.      Windows::.).  If it is non-`nil', these lines are truncated;
  733.      otherwise, `truncate-lines' says what to do with them.
  734.    You can override the images that indicate continuation or truncation
  735. with the display table; see *Note Display Tables::.
  736.    If your buffer contains *very* long lines, and you use continuation
  737. to display them, just thinking about them can make Emacs redisplay
  738. slow.  The column computation and indentation functions also become
  739. slow.  Then you might find it advisable to set `cache-long-line-scans'
  740. to `t'.
  741.  - Variable: cache-long-line-scans
  742.      If this variable is non-`nil', various indentation and motion
  743.      functions, and Emacs redisplay, cache the results of scanning the
  744.      buffer, and consult the cache to avoid rescanning regions of the
  745.      buffer unless they are modified.
  746.      Turning on the cache slows down processing of short lines somewhat.
  747.      This variable is automatically local in every buffer.
  748. File: elisp,  Node: The Echo Area,  Next: Invisible Text,  Prev: Truncation,  Up: Display
  749. The Echo Area
  750. =============
  751.    The "echo area" is used for displaying messages made with the
  752. `message' primitive, and for echoing keystrokes.  It is not the same as
  753. the minibuffer, despite the fact that the minibuffer appears (when
  754. active) in the same place on the screen as the echo area.  The `GNU
  755. Emacs Manual' specifies the rules for resolving conflicts between the
  756. echo area and the minibuffer for use of that screen space (*note The
  757. Minibuffer: (emacs)Minibuffer.).  Error messages appear in the echo
  758. area; see *Note Errors::.
  759.    You can write output in the echo area by using the Lisp printing
  760. functions with `t' as the stream (*note Output Functions::.), or as
  761. follows:
  762.  - Function: message STRING &rest ARGUMENTS
  763.      This function displays a one-line message in the echo area.  The
  764.      argument STRING is similar to a C language `printf' control
  765.      string.  See `format' in *Note String Conversion::, for the details
  766.      on the conversion specifications.  `message' returns the
  767.      constructed string.
  768.      In batch mode, `message' prints the message text on the standard
  769.      error stream, followed by a newline.
  770.      If STRING is `nil', `message' clears the echo area.  If the
  771.      minibuffer is active, this brings the minibuffer contents back onto
  772.      the screen immediately.
  773.           (message "Minibuffer depth is %d."
  774.                    (minibuffer-depth))
  775.            -| Minibuffer depth is 0.
  776.           => "Minibuffer depth is 0."
  777.           
  778.           ---------- Echo Area ----------
  779.           Minibuffer depth is 0.
  780.           ---------- Echo Area ----------
  781.    Almost all the messages displayed in the echo area are also recorded
  782. in the `*Messages*' buffer.
  783.  - User Option: message-log-max
  784.      This variable specifies how many lines to keep in the `*Messages*'
  785.      buffer.  The value `t' means there is no limit on how many lines to
  786.      keep.  The value `nil' disables message logging entirely.  Here's
  787.      how to display a message and prevent it from being logged:
  788.           (let (message-log-max)
  789.             (message ...))
  790.  - Variable: echo-keystrokes
  791.      This variable determines how much time should elapse before command
  792.      characters echo.  Its value must be an integer, which specifies the
  793.      number of seconds to wait before echoing.  If the user types a
  794.      prefix key (such as `C-x') and then delays this many seconds before
  795.      continuing, the prefix key is echoed in the echo area.  Any
  796.      subsequent characters in the same command will be echoed as well.
  797.      If the value is zero, then command input is not echoed.
  798.  - Variable: cursor-in-echo-area
  799.      This variable controls where the cursor appears when a message is
  800.      displayed in the echo area.  If it is non-`nil', then the cursor
  801.      appears at the end of the message.  Otherwise, the cursor appears
  802.      at point--not in the echo area at all.
  803.      The value is normally `nil'; Lisp programs bind it to `t' for
  804.      brief periods of time.
  805. File: elisp,  Node: Invisible Text,  Next: Selective Display,  Prev: The Echo Area,  Up: Display
  806. Invisible Text
  807. ==============
  808.    You can make characters "invisible", so that they do not appear on
  809. the screen, with the `invisible' property.  This can be either a text
  810. property or a property of an overlay.
  811.    In the simplest case, any non-`nil' `invisible' property makes a
  812. character invisible.  This is the default case--if you don't alter the
  813. default value of `buffer-invisibility-spec', this is how the
  814. `invisibility' property works.  This feature is much like selective
  815. display (*note Selective Display::.), but more general and cleaner.
  816.    More generally, you can use the variable `buffer-invisibility-spec'
  817. to control which values of the `invisible' property make text
  818. invisible.  This permits you to classify the text into different subsets
  819. in advance, by giving them different `invisible' values, and
  820. subsequently make various subsets visible or invisible by changing the
  821. value of `buffer-invisibility-spec'.
  822.    Controlling visibility with `buffer-invisibility-spec' is especially
  823. useful in a program to display the list of entries in a data base.  It
  824. permits the implementation of convenient filtering commands to view
  825. just a part of the entries in the data base.  Setting this variable is
  826. very fast, much faster than scanning all the text in the buffer looking
  827. for properties to change.
  828.  - Variable: buffer-invisibility-spec
  829.      This variable specifies which kinds of `invisible' properties
  830.      actually make a character invisible.
  831.     `t'
  832.           A character is invisible if its `invisible' property is
  833.           non-`nil'.  This is the default.
  834.     a list
  835.           Each element of the list makes certain characters invisible.
  836.           Ultimately, a character is invisible if any of the elements
  837.           of this list applies to it.  The list can have two kinds of
  838.           elements:
  839.          `ATOM'
  840.                A character is invisible if its `invisible' propery value
  841.                is ATOM or if it is a list with ATOM as a member.
  842.          `(ATOM . t)'
  843.                A character is invisible if its `invisible' propery value
  844.                is ATOM or if it is a list with ATOM as a member.
  845.                Moreover, if this character is at the end of a line and
  846.                is followed by a visible newline, it displays an
  847.                ellipsis.
  848.    Ordinarily, commands that operate on text or move point do not care
  849. whether the text is invisible.  The user-level line motion commands
  850. explicitly ignore invisible newlines if `line-move-ignore-invisible' is
  851. non-`nil', but only because they are explicitly programmed to do so.
  852. File: elisp,  Node: Selective Display,  Next: Overlay Arrow,  Prev: Invisible Text,  Up: Display
  853. Selective Display
  854. =================
  855.    "Selective display" is a pair of features that hide certain lines on
  856. the screen.
  857.    The first variant, explicit selective display, is designed for use in
  858. a Lisp program.  The program controls which lines are hidden by altering
  859. the text.  Outline mode has traditionally used this variant.  It has
  860. been partially replaced by the invisible text feature (*note Invisible
  861. Text::.); there is a new version of Outline mode which uses that
  862. instead.
  863.    In the second variant, the choice of lines to hide is made
  864. automatically based on indentation.  This variant is designed to be a
  865. user-level feature.
  866.    The way you control explicit selective display is by replacing a
  867. newline (control-j) with a carriage return (control-m).  The text that
  868. was formerly a line following that newline is now invisible.  Strictly
  869. speaking, it is temporarily no longer a line at all, since only newlines
  870. can separate lines; it is now part of the previous line.
  871.    Selective display does not directly affect editing commands.  For
  872. example, `C-f' (`forward-char') moves point unhesitatingly into
  873. invisible text.  However, the replacement of newline characters with
  874. carriage return characters affects some editing commands.  For example,
  875. `next-line' skips invisible lines, since it searches only for newlines.
  876. Modes that use selective display can also define commands that take
  877. account of the newlines, or that make parts of the text visible or
  878. invisible.
  879.    When you write a selectively displayed buffer into a file, all the
  880. control-m's are output as newlines.  This means that when you next read
  881. in the file, it looks OK, with nothing invisible.  The selective display
  882. effect is seen only within Emacs.
  883.  - Variable: selective-display
  884.      This buffer-local variable enables selective display.  This means
  885.      that lines, or portions of lines, may be made invisible.
  886.         * If the value of `selective-display' is `t', then any portion
  887.           of a line that follows a control-m is not displayed.
  888.         * If the value of `selective-display' is a positive integer,
  889.           then lines that start with more than that many columns of
  890.           indentation are not displayed.
  891.      When some portion of a buffer is invisible, the vertical movement
  892.      commands operate as if that portion did not exist, allowing a
  893.      single `next-line' command to skip any number of invisible lines.
  894.      However, character movement commands (such as `forward-char') do
  895.      not skip the invisible portion, and it is possible (if tricky) to
  896.      insert or delete text in an invisible portion.
  897.      In the examples below, we show the *display appearance* of the
  898.      buffer `foo', which changes with the value of `selective-display'.
  899.      The *contents* of the buffer do not change.
  900.           (setq selective-display nil)
  901.                => nil
  902.           
  903.           ---------- Buffer: foo ----------
  904.           1 on this column
  905.            2on this column
  906.             3n this column
  907.             3n this column
  908.            2on this column
  909.           1 on this column
  910.           ---------- Buffer: foo ----------
  911.           
  912.           (setq selective-display 2)
  913.                => 2
  914.           
  915.           ---------- Buffer: foo ----------
  916.           1 on this column
  917.            2on this column
  918.            2on this column
  919.           1 on this column
  920.           ---------- Buffer: foo ----------
  921.  - Variable: selective-display-ellipses
  922.      If this buffer-local variable is non-`nil', then Emacs displays
  923.      `...' at the end of a line that is followed by invisible text.
  924.      This example is a continuation of the previous one.
  925.           (setq selective-display-ellipses t)
  926.                => t
  927.           
  928.           ---------- Buffer: foo ----------
  929.           1 on this column
  930.            2on this column ...
  931.            2on this column
  932.           1 on this column
  933.           ---------- Buffer: foo ----------
  934.      You can use a display table to substitute other text for the
  935.      ellipsis (`...').  *Note Display Tables::.
  936. File: elisp,  Node: Overlay Arrow,  Next: Temporary Displays,  Prev: Selective Display,  Up: Display
  937. The Overlay Arrow
  938. =================
  939.    The "overlay arrow" is useful for directing the user's attention to
  940. a particular line in a buffer.  For example, in the modes used for
  941. interface to debuggers, the overlay arrow indicates the line of code
  942. about to be executed.
  943.  - Variable: overlay-arrow-string
  944.      This variable holds the string to display to call attention to a
  945.      particular line, or `nil' if the arrow feature is not in use.
  946.  - Variable: overlay-arrow-position
  947.      This variable holds a marker that indicates where to display the
  948.      overlay arrow.  It should point at the beginning of a line.  The
  949.      arrow text appears at the beginning of that line, overlaying any
  950.      text that would otherwise appear.  Since the arrow is usually
  951.      short, and the line usually begins with indentation, normally
  952.      nothing significant is overwritten.
  953.      The overlay string is displayed only in the buffer that this marker
  954.      points into.  Thus, only one buffer can have an overlay arrow at
  955.      any given time.
  956.    You can do the same job by creating an overlay with a
  957. `before-string' property.  *Note Overlay Properties::.
  958.